const mongoose = require('mongoose');

const MarketItemSchema = new mongoose.Schema({
  title: {
    type: String,
    required: true
  },
  description: {
    type: String,
    required: true
  },
  price: {
    type: String, // 改为 String 类型以支持文本描述
    required: true
  },
  category: {
    type: String,
    enum: ['digital', 'books', 'clothing', 'transportation', 'other', 'digital_accessories', 'sports_equipment', 'photography_equipment', 'household_appliances'],
    default: 'other'
  },
  condition: {
    type: String,
    enum: ['new', 'like_new', 'good', 'fair', 'poor'],
    required: true
  },
  images: [String],
  userId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User'
  },
  contact: String,
  createdAt: {
    type: Date,
    default: Date.now
  }
});

module.exports = mongoose.model('MarketItem', MarketItemSchema);
